<?php
include('../inc/db.inc.php');
include('../inc/functions.inc.php');

$s = get_settings();

// Build message string
$message = "A contact form was submitted at your site. Here is the information received:\n\r\n\r";
while (list($key, $val) = each($_POST)) {
	if ($key != "onLoad") {
		$message .= "$key: $val\n\r";
	}
}

// Send email if we're supposed to
$recip = $s['email'];
$sub = "Contact Form Submitted";
$headers = "From: $recip\r\n";
$headers .= "Reply-To: $recip\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();
if ($s['contact_form_email'] == 1) {
	mail($recip, $sub, $message);
}

// Save data in messages table
$q = "insert into messages (type,date,body) values ('CONTACT',Now(),'$message')";
$ins = mysql_query($q)
	or die(mysql_error());

?>

<p>Your information has been sent. Thank you.</p>
